<template>
  <a-modal
    :title="title"
    v-model="show"
    :maskClosable="false"
    :width="1050"
    placement="right"
    :closable="true"
    @cancel="onClose"
    :footer="null"
    :visiable="statusDetailVisiable"
  >
    <a-form :form="form">
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="调账状态"
                       v-bind="formItemLayout">
            <a-select
              mode="default"
              :allowClear="true"
              style="width: 100%"
              show-search
              placeholder="请选择"
              option-filter-prop="children"
              :filter-option="filterOption"
              :disabled="true"
              v-decorator="['AcctStatus',{rules: [{ required: true, message: '必填' }]}]">
              <a-select-option key="00">待记账</a-select-option>
              <a-select-option key="01">记账成功</a-select-option>
              <a-select-option key="02">记账失败</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="失败原因"
                       v-bind="formItemLayout">
            <a-textarea v-decorator="['FailureReason',{rules: [{ required: true, message: '必填' }]}]"/>
          </a-form-item>
        </a-col>
      </a-row>
      <a-row>
        <a-col :md="12" :sm="24">
          <a-form-item label="核心日期"
                       v-bind="formItemLayout">
            <a-input v-decorator="['AcctDate',{rules: [{ required: true, message: '必填' }]}]"/>
          </a-form-item>
        </a-col>
        <a-col :md="12" :sm="24">
          <a-form-item label="核心流水号"
                       v-bind="formItemLayout">
            <a-input v-decorator="['AcctSeqNum',{rules: [{ required: true, message: '必填' }]}]"/>
          </a-form-item>
        </a-col>
      </a-row>
      <br>

    </a-form>

  </a-modal>
</template>
<script>
  const formItemLayout = {
    labelCol: {span: 8},
    wrapperCol: {span: 16}
  }
  export default {
    name: 'StatusDetail',
    props: {
      statusDetailVisiable: {
        default: false
      },
      instId: '',
    },
    data() {
      return {
        title: '调账状态',
        loading: false,
        formItemLayout,
        form: this.$form.createForm(this),
        validateStatus: '',

        info: {

        }
      }
    },
    computed: {
      show: {
        get: function () {
          return this.statusDetailVisiable
        },
        set: function () {
        }
      }
    },
    mounted() {

    },

    methods: {
      filterOption(input, option) {
        return (
          option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
        );
      },

      reset() {
        this.loading = false
        this.form.resetFields()
      },
      onClose() {
        this.reset()
        this.$emit('close')
      },

      setStatusDetailFormValues({...info}) {
        let fields = ['AcctStatus', 'FailureReason', 'AcctDate', 'AcctSeqNum']

        Object.keys(info).forEach((key) => {
          if (fields.indexOf(key) !== -1) {
            this.form.getFieldDecorator(key)
            let obj = {}
            obj[key] = info[key]
            this.form.setFieldsValue(obj)
          }
        })
      },

    }

  }
</script>





